<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="/css/public.css"/>
    <script src="/static/js/jquery-1.8.3.min.js"></script>
    <script src="/static/js/layer/layer.js"></script>
    <style>

        body{
            background: url("/imgs/bg.png") center center;
        }
        .main{
            width: 600px;
            height: 920px;
            margin: 30px auto 0;
            background: #ffffff;
            border-radius: 6px;
        }
        .top{
            position: relative;
            padding-top: 40px;
        }
        .top h2{
            text-align: center;
            color:#1c9ed0;
        }
        .top span{
            right: 40px;
            bottom: 0;
            position: absolute;
            cursor: pointer;
        }
        .center{
            padding-left: 80px;
        }
        .center .one{
            margin-top: 25px;
            height: 30px;
            line-height: 30px;
            width: 360px;
        }
        .center .two{
            margin-top: 20px;
            height: 280px;
            line-height: 30px;
            position: relative;
            width: 360px;
        }

        .center .one p, .center .two p{
            float: left;
            margin-right: 20px;
            width: 100px;
            text-align: right;
        }
        .center .one input{
            width: 240px;
            height: 28px;
            box-sizing: border-box;
            padding-left: 6px;
        }
        .center .two  img{
            width: 200px;
            height: 280px;
        }
        .center .two .shangchuang{
            width: 130px;
            height: 30px;
            background: url("/image/upload.png");
            color: white;
            position: absolute;
            text-align: center;
            left:155px;
            top:50%;
            margin-top: -15px;
            cursor: pointer;
        }
        .center .two .shangchuang input{
            opacity: 0;
        }
        .center .save{
            cursor: pointer;
            margin-top: 30px;
            margin-left: 80px;
            color: white;
            background: rgb(59,174,218);
            width: 100px;
            height: 30px;
            line-height: 30px;
            text-align: center;
        }
        .center .text{
            line-height: 150%;
            margin-top: 10px;
            padding-left: 80px;
            font-size: 14px;
        }
    </style>

</head>
<body>
    <div class="all">
        <form>
      <div class="main">
           <div class="top"><h2>品牌代理系统</h2> <span><a href="{{urlAdmin('Login','getLogin')}}">返回登录</a></span></div>
          <div class="center">
              <div class="one">
                  <p>手机号</p>
                  <input type="text" name="mobile" />
              </div>
              <div class="one">
                  <p>密码</p>
                  <input type="password" name="password" />
              </div>
              <div class="one">
                  <p>确认密码</p>
                  <input type="password" name="cpassword" />
              </div>
              <div class="one">
                  <p>品牌名称</p>
                  <input type="text" name="brand_name" />
              </div>
              <div class="one">
                  <p>负责人</p>
                  <input type="text" name="name" />
              </div>

              <div class="one">
                  <p>地址</p>
                  <input type="text" name="address" />
              </div>
              <div class="two">
                  <p>营业执照</p>
                  <img id='oldImg' src="/imgs/zhengshu.png" alt=""/>
                  <span class="shangchuang"><input type="file" id="file" value="上传图片"></span>
                  <input type="hidden" id='img' name="img">
              </div>
              <div class="save" id='zhuce'>提交注册</div>
              <p class="text">提交注册申请需要等待审核 <br/>审核结果以短信方式发送</p>
          </div>
      </div>
        </form>
    </div>
</body>
</html>
<script>
    $(function(){


        //h5上传图片
        var oFile = document.getElementById('file');
        var oldImg = document.getElementById('oldImg');
        var oImg = document.getElementById('img');

        oFile.onchange = function(){

            var file = this.files[0];

            var reader = new FileReader();

            reader.readAsDataURL(file);   //将文件读取为DataUrl

            //读完了之后就能调取数据了
            reader.onload = function(){
                //console.log(reader.result);
                //在div中添加dom
                //在隐藏标签中添加value
                oldImg.src = reader.result;
                oImg.value = reader.result;
            }

        }


        $('#zhuce').click(function(){
                $.ajax({
                    type:'post',
                    url:'{{url("center/register")}}',
                    data:$('form').serializeArray(),
                    dataType:'json',
                    success:function(res){
                        //关闭所有层
                        //layer.closeAll();
                        if(res.status==1){
                            layer.msg(res.msg, {icon: 6});
                            setTimeout('location.href="{{url('center/login')}}"',3000);
                        }else{
                            layer.msg(res.msg, {icon: 5});
                        }
                    }
                });
        });





    });

</script>